//  n<=15
#include <bits/stdc++.h>
using namespace std;
int n;
int a[105];
int blue=0,red=0;
int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
int search1(int x,int ans){
    if(x==n+1){
        return ans;
    }
    int ans1=0,b=blue;
    if(a[x]==a[blue]){ //fill a[x] blue
        blue=x;
        ans1=search1(x+1,ans+a[x]);
    }else{
        blue=x;
        ans1=max(ans1,search1(x+1,ans));
    }
    blue=b;

    int ans2=0,r=red;
    if(a[x]==a[red]){ //fill a[x] red
        red=x;
        ans1=search1(x+1,ans+a[x]);
    }else{
        red=x;
        ans1=max(ans1,search1(x+1,ans));
    }
    red=r;
    return max(ans1,ans2);
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T=read();
    while(T--){
        red=0,blue=0,a[0]=-1;
        n=read();
        for(int i=1;i<=n;i++){
            a[i]=read();
        }
        printf("%d\n",search1(1,0));
    }
    return 0;
}
/*
3
3
1 2 1
4
1 2 3 4
8
3 5 2 5 1 2 1 4
*/
